////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    SunkenTreasureGuts.h                                         //
//  Developer:   Lynn Akers                                                   //
//  Create date: 10/11/2005                                                   //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class declaration for the slot gut of the        //
//               Australian Slot machine called Sunken Treasure.              //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        Copyright (c) 2005 - Realtime Gaming.  All rights reserved.         //
////////////////////////////////////////////////////////////////////////////////

#ifndef __SUNKENTREASUREGUTS_H__
#define __SUNKENTREASUREGUTS_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "slotguts.h"
#include "getrand.h"

class SunkenTreasureGuts : public SlotGuts
{
public:
	SunkenTreasureGuts();

	virtual ~SunkenTreasureGuts();

private:
	// Shared enums between client and server
	#include "SunkenTreasureCommon.h"

	// Helpful lookup arrays.
	static SpinResult m_aLineWinSpinResults[NUM_VALID_ICONS][6];

	static SpinResult m_aScatterWinSpinResults[6];

	// Inline functions to use with the arrays that also do
	// bounds checking.
	static SpinResult lookupLineWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static SpinResult lookupScatterWinSpinResult( uint8 nCount )
	{
		if ( nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	// Helper functions for classifyStops.
	void tryForJackpot( SlotSpin* spin );
	SpinResult getScatterWinResult( SlotSpin* spin, int32& scatterPositions ) const;
	void evaluateScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions );
	void evaluateFeatureTrigger( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions );

public:
	virtual void classifyStops( SpinLine* spinline, uint8* stops, uint8 bet, uint8 line,
		uint8& rtnresult, uint8& multiplier );

	virtual void classifyScatters( SlotSpin *spin );

    virtual bool8 isValidGuts();
    // virtual void  getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId );
	virtual bool8 processClientData(uint8 bonusGameType, int32 bonusDataCount, int32 *bonusData);

	virtual bool8 hasSavedGames();

	virtual void  getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId );



protected:
	void initializeBonusGame(int32 nTreasurePicks);

	void awardFreeSpins();

	void  setFeatureGameMultiplier(int32 nFeatureGameMultiplier);
	int32 getFeatureGameMultiplier() const;

	void  setTreasurePicksAwarded( int32 nTreasurePicks );
	int32 getTreasurePicksAwarded() const;
	int32 getTreasurePicksRemaining() const;
	int32 getCurrentTreasureIndex() const;
	void  setTreasureChestWinType( int32 nPick, int32 nWinType );
	int32 getTreasureChestWinType( int32 nPick ) const;
	void  setTreasureChestWinAmount( int32 nPick, int32 nAmount ); 
	int32 getTreasureChestWinAmount( int32 nPick ) const;
	void  setTreasureChestForPick( int32 nPick, int32 nChest );
	int32 getTreasureChestForPick( int32 nPick ) const;
	void  setTreasureChestJewelType( int32 nPick, int32 nJewelType );
	int32 getTreasureChestJewelType( int32 nPick ) const;

	void  setJewelChestForPick( int32 nPick, int32 nChest );
	int32 getJewelChestForPick( int32 nPick ) const;
	void  setJewelPickWinAmount( int32 nPick, int32 nAmount ); 
	int32 getJewelPickWinAmount( int32 nPick ) const;

	void  updateTreasureChestSelectedMask( int32 nChest );
	void  setTreasureChestSelectedMask( int32 nMask );
	int32 getTreasureChestSelectedMask() const;
	
	void  updateJewelPickSelectedMask( int32 nChest );
	void  setJewelPickSelectedMask( int32 nMask );
	int32 getJewelPickSelectedMask() const;

	bool  isTreasureChestSelected( int32 nChest ) const;
	bool  isJewelChestSelected( int32 nChest ) const;
	
	void  initializeBonusGameResultIndex();
	int32 postIncrementBonusGameResultIndex();
	int32 getBonusGameResultIndex() const;

	void  initializeCurrentTreasureIndex();
	void  incrementCurrentTreasureIndex();

	int32 getJewelPicksAwarded() const;
	int32 getJewelPicksRemaining() const;
	void  initializeJewelPicksAwarded();
	void  incrementJewelPicksAwarded();
	
	int32 getCurrentJewelIndex() const;
	void  initializeCurrentJewelIndex();
	void  incrementCurrentJewelIndex();

	// Override of the framework function.
	virtual void preSpinClassifyResults( SlotSpin *spin );
	virtual void postSpinClassifyResults( SlotSpin *spin );
};

#endif // __SUNKENTREASUREGUTS_H__
